<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
JsWs Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="virtualpath.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b>JsWs</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>virtualpath.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		No overview generated for 'virtualpath.js'<BR/><BR/>
	
</p>

<hr>


    <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
    <td colspan=2><font size="+2">
    
        <b>Class Summary</b>
    
    </font></td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="VirtualPath.html">VirtualPath</a></b></td>
    <td>Virtual server paths
 </td>
    </tr>
    
    </table>
    <hr/> 


<!-- ========== METHOD SUMMARY =========== -->

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">/* ***** BEGIN LICENSE BLOCK *****
 *   Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 * 
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is JsWs.
 *
 * The Initial Developer of the Original Code is
 * Chris Winberry.
 * Portions created by the Initial Developer are Copyright (C) 2007
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 * 
 * ***** END LICENSE BLOCK ***** */</span>

<span class="comment">/**
 * <span class="attrib">@class</span> Virtual server paths
 * <span class="attrib">@contructor</span>
 * <span class="attrib">@param</span> {String} path Server-relative path to initialize with
 */</span>
<span class="reserved">function</span> VirtualPath (path) {
	<span class="comment">/**
	 * Current virtual mapped path
	 * <span class="attrib">@type</span> {String}
	 */</span>
	<span class="reserved">this</span>.path = <span class="literal">""</span>;
	<span class="reserved">this</span>.initWithPath(path);
}

<span class="comment">/**
 * Sets the virtual path's location
 * <span class="attrib">@param</span> {String} path Server-relative path to initialize with
 */</span>
VirtualPath.initWithPath = <span class="reserved">function</span> (path) {
	<span class="reserved">if</span> (path == null || path.length &lt; 1)
		path = VirtualPath.virtSeparator;

	<span class="reserved">this</span>.path = <span class="reserved">this</span>.virtSeparator + <span class="reserved">this</span>.virtNrml(path);
}
<span class="comment">/** <span class="attrib">@private</span> */</span>
VirtualPath.<span class="reserved">prototype</span>.initWithPath = VirtualPath.initWithPath;

<span class="comment">/**
 * System path separator
 * <span class="attrib">@type</span> String
 */</span>
VirtualPath.sysSeparator = Cc[<span class="literal">"@mozilla.org/file/directory_service;1"</span>]
	.getService(Ci.nsIProperties)
	.get(<span class="literal">'ProfD'</span>, Ci.nsILocalFile)
	.path.match(<span class="literal">'/'</span>) ? <span class="literal">'/'</span> : <span class="literal">'\\'</span>;
<span class="comment">/** <span class="attrib">@private</span> */</span>
VirtualPath.<span class="reserved">prototype</span>.sysSeparator = VirtualPath.sysSeparator;

<span class="comment">/**
 * Server/virtual path separator
 * <span class="attrib">@type</span> String
 */</span>
VirtualPath.virtSeparator = <span class="literal">"/"</span>;
<span class="comment">/** <span class="attrib">@private</span> */</span>
VirtualPath.<span class="reserved">prototype</span>.virtSeparator = VirtualPath.virtSeparator;

<span class="comment">/**
 * System's root path
 * <span class="attrib">@type</span> String
 */</span>
VirtualPath.sysRoot = Cc[<span class="literal">"@mozilla.org/file/directory_service;1"</span>]
	.getService(Ci.nsIProperties)
	.get(<span class="literal">'ProfD'</span>, Ci.nsILocalFile)
	.path.match(/^([\w]\:|\/|\\)/i)[0];
<span class="comment">/** <span class="attrib">@private</span> */</span>
VirtualPath.<span class="reserved">prototype</span>.sysRoot = VirtualPath.sysRoot;

<span class="comment">/**
 * Server's root path
 * <span class="attrib">@type</span> String
 */</span>
VirtualPath.virtRoot = VirtualPath.virtSeparator;
<span class="comment">/** <span class="attrib">@private</span> */</span>
VirtualPath.<span class="reserved">prototype</span>.virtRoot = VirtualPath.virtRoot;

<span class="comment">/**
 * Appends the passed in path to the current path
 * <span class="attrib">@param</span> {String} path Path to append
 */</span>
VirtualPath.<span class="reserved">prototype</span>.append = <span class="reserved">function</span> (path) {
	var parts = <span class="reserved">this</span>.virtNrml(<span class="reserved">this</span>.path).split(<span class="reserved">this</span>.virtSeparator);
	var newParts = <span class="reserved">this</span>.virtNrml(path).split(<span class="reserved">this</span>.virtSeparator);

	<span class="reserved">for</span> (var i = 0; i &lt; newParts.length; i++) {
		<span class="reserved">if</span> (newParts[i] == <span class="literal">".."</span>) {
			<span class="reserved">if</span> (parts.length &gt; 0) {
				parts.pop();
			}
		}
		<span class="reserved">else</span> <span class="reserved">if</span> (newParts[i] != <span class="literal">"."</span>) {
			parts.push(newParts[i]);
		}
	}
	<span class="reserved">this</span>.initWithPath(parts.join(<span class="reserved">this</span>.virtSeparator));
}

<span class="comment">/**
 * Creates a copy of the current VirtualPath instance
 * <span class="attrib">@returns</span> New instance of VirtualPath
 * <span class="attrib">@type</span> VirtualPath
 */</span>
VirtualPath.<span class="reserved">prototype</span>.clone = <span class="reserved">function</span> () {
	<span class="reserved">return</span>(new VirtualPath(<span class="reserved">this</span>.path));
}

<span class="comment">/**
 * Returns a VirtualPath instance of the parent folder
 * <span class="attrib">@returns</span> New instance of VirtualPath
 * <span class="attrib">@type</span> VirtualPath
 */</span>
VirtualPath.<span class="reserved">prototype</span>.parent = <span class="reserved">function</span> () {
	var parts = <span class="reserved">this</span>.virtNrml(<span class="reserved">this</span>.path).split(<span class="reserved">this</span>.virtSeparator);
	parts.pop();
	<span class="reserved">return</span>(new VirtualPath(parts.join(<span class="reserved">this</span>.virtSeparator)));
}

<span class="comment">/** <span class="attrib">@private</span> */</span>
VirtualPath.normalize = <span class="reserved">function</span> (path, separator) {
	<span class="reserved">if</span> ((path instanceof Ci.nsILocalFile) | (path instanceof VirtualPath))
		path = path.path;
	<span class="reserved">return</span>(path.replace(/(^(\/|\\)+|(\/|\\)+$)/g, <span class="literal">""</span>).replace(/(\/|\\)+/g, separator));
}
<span class="comment">/** <span class="attrib">@private</span> */</span>
VirtualPath.<span class="reserved">prototype</span>.normalize = VirtualPath.normalize;

<span class="comment">/**
 * Cleans up a path and converts to using the system path seprator
 * <span class="attrib">@param</span> {String} path Path to normalize
 * <span class="attrib">@returns</span> System normalized path
 * <span class="attrib">@type</span> String
 */</span>
VirtualPath.sysNrml = <span class="reserved">function</span> (path) { <span class="reserved">return</span>(VirtualPath.normalize(path, VirtualPath.sysSeparator)); }
<span class="comment">/** <span class="attrib">@private</span> */</span>
VirtualPath.<span class="reserved">prototype</span>.sysNrml = VirtualPath.sysNrml;

<span class="comment">/**
 * Cleans up a path and converts to using the server/virtual path seprator
 * <span class="attrib">@param</span> {String} path Path to normalize
 * <span class="attrib">@returns</span> Server/virtual normalized path
 * <span class="attrib">@type</span> String
 */</span>
VirtualPath.virtNrml = <span class="reserved">function</span> (path) { <span class="reserved">return</span>(VirtualPath.normalize(path, VirtualPath.virtSeparator)); }
<span class="comment">/** <span class="attrib">@private</span> */</span>
VirtualPath.<span class="reserved">prototype</span>.virtNrml = VirtualPath.virtNrml;
</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b>JsWs</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Thu Nov  8 22:50:16 2007</div>
</body>
</html>
